import request from '@/utils/request';

export function getMenu(id: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/menu',
		params: { parentId: id },
		method: 'get',
	});
}

export function getTopMenu(): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/menu',
		params: { type: 'top' },
		method: 'get',
	});
}

export function fetchMenuTree(params?: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/menu/tree',
		method: 'get',
		params: params,
	});
}

export function addObj(obj: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/menu',
		method: 'post',
		data: obj,
	});
}

export function getObj(id: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/menu/' + id,
		method: 'get',
	});
}

export function delObj(id: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/menu/' + id,
		method: 'delete',
	});
}

export function putObj(obj: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/menu',
		method: 'put',
		data: obj,
	});
}
